﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
	Inherits="System.Web.Mvc.ViewPage<IEnumerable<IBrand>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%: "Index".Localize()%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<h3 class="title">
		<%: "Brands".Localize()%></h3>
<div class="command clearfix">
	<%: Html.ActionLink("Create new Brand".Localize(), "Create", null, new { @class = "button" })%>
</div>

	<div class="table-container">
		<table>
			<thead>
				<tr>
					<th>
						<% string sort = (ViewData["sort"] == "desc" ? "asc" : "desc");
		 string currentSort = (ViewData["sort"] == "desc" ? "desc" : "asc");
						%>
						<%= Html.ActionLink("Name".Localize(), "Index", new { sort = sort }, new { @class = "sort " + currentSort })%>
					</th>
					<th>
						<%: "Description".Localize() %>
					</th>
					<th class="action">
						<%: "Edit".Localize() %>
					</th>
					<th class="action">
						<%: "Delete".Localize() %>
					</th>
				</tr>
			</thead>
			<tbody>
				<% 
					var index = 0;
					foreach (var item in Model)
					{
				%>
				<tr <% if (++index % 2 == 0) {%>class="even" <%} %>>
					<td>
						<%: item.Name %>
					</td>
					<td>
						<%: item.Description %>
					</td>
					<td class="action">
						<%: Html.ActionLink(" ","Edit","Brand",new { id = item.Id},new {@class="o-icon edit"}) %>
					</td>
					<td class="action">
						<% using (Html.BeginForm("Delete", "Brand"))
		 {
						%>
						<%: Html.Hidden("Id",item.Id) %>
						<a class="o-icon input-icon delete delete-link" href=# message='<%= "Are you sure you want to delete this brand?".Localize() %>'></a>
						<%} %>
					</td>
				</tr>
				<%}
				%>
			</tbody>
		</table>
	</div>
	<script type="text/javascript">
	var message_delete_confirm = "<%= "This brand will be delete. \\r\\n And its products will be moved to the brand 'None'.".Localize() %>";
	</script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <%using (var loader = ClientLoader.RegisterInstance())
      {
          loader.Require("brand.index.js");
      } %>
</asp:Content>
